package com.hddznet.uniplatform.sm.entity;

import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hddznet.uniplatform.sm.constant.StatusEnum;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class BaseEntity {

	/**ID*/
	@TableId(value = "id", type = IdType.UUID)
	private String id;
	
	/**状态*/
	@TableField(value = "status")
	private Integer status;
	
	/**creater*/
	@TableField(value = "creater")
	private String creater;
	
	/**createTime*/
	@ApiModelProperty(value = "创建时间", name = "createTime", required = false,  example = "2020-01-01 01:01:01")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	@TableField(value = "create_time")
	private Date createTime;
	
	/**updater*/
	@TableField(value = "updater")
	private String updater;
	
	/**updateTime*/
	@ApiModelProperty(value = "修改时间", name = "updateTime", required = false,  example = "2020-01-01 01:01:01")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	@TableField(value = "update_time")
	private Date updateTime;
	
	public void setDefaultStatus() {
		if (!StatusEnum.Deleted.key().equals(this.getStatus())) {
			this.setStatus(StatusEnum.Normal.key());
		}
	}
}
